/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Inicio.java
 *
 * Created on 25/08/2011, 07:26:05 PM
 */

package GUI;

//import GUI.AdministracionPlantillas.Plantillas;
import java.awt.BorderLayout;
import javax.swing.JFrame;

/**
 *
 * @author CarLita
 */
public class Inicio extends javax.swing.JPanel {
    Principal ventanaPrincipal;


    /** Creates new form Inicio */
    public Inicio() {
        initComponents();
    }

    public Inicio(Principal ventanaPrincipal) {
        this.ventanaPrincipal = ventanaPrincipal;
        initComponents();
        bloquearPorPermisos();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        lblPlantillas = new javax.swing.JLabel();
        lblProyectos = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        lblUsuarios = new javax.swing.JLabel();

        setMinimumSize(new java.awt.Dimension(800, 610));
        setPreferredSize(new java.awt.Dimension(800, 620));
        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/imagenes/cat.png"))); // NOI18N
        add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 200, -1, -1));

        lblPlantillas.setFont(new java.awt.Font("Verdana", 0, 18));
        lblPlantillas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/Imagenes/plantilla.png"))); // NOI18N
        lblPlantillas.setText("Plantillas");
        lblPlantillas.setFocusable(false);
        lblPlantillas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        lblPlantillas.setVerifyInputWhenFocusTarget(false);
        lblPlantillas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        lblPlantillas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblPlantillasMouseClicked(evt);
            }
        });
        add(lblPlantillas, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 50, -1, -1));

        lblProyectos.setFont(new java.awt.Font("Verdana", 0, 18)); // NOI18N
        lblProyectos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/Imagenes/project.png"))); // NOI18N
        lblProyectos.setText("Proyectos");
        lblProyectos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        lblProyectos.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        lblProyectos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblProyectosMouseClicked(evt);
            }
        });
        add(lblProyectos, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 50, -1, -1));

        jLabel4.setFont(new java.awt.Font("Verdana", 0, 18));
        jLabel4.setIcon(new javax.swing.ImageIcon("C:\\Users\\CarLita\\Desktop\\Tesis\\Iconos\\reportes.png")); // NOI18N
        jLabel4.setText("Reporte");
        jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jLabel4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 290, -1, -1));

        lblUsuarios.setFont(new java.awt.Font("Verdana", 0, 18));
        lblUsuarios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/Imagenes/people.png"))); // NOI18N
        lblUsuarios.setText("Usuarios");
        lblUsuarios.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        lblUsuarios.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        lblUsuarios.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblUsuariosMouseClicked(evt);
            }
        });
        add(lblUsuarios, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 310, -1, -1));
    }// </editor-fold>//GEN-END:initComponents

    private void lblPlantillasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblPlantillasMouseClicked
        ventanaPrincipal.panelInicio.setVisible(false);
        ventanaPrincipal.panelContenedor.remove(ventanaPrincipal.panelInicio);

        ventanaPrincipal.panelContenedor.add(ventanaPrincipal.panelBotonesPlantillas, BorderLayout.NORTH);
        ventanaPrincipal.panelContenedor.add(ventanaPrincipal.panelPlantillas, BorderLayout.SOUTH);

        ventanaPrincipal.panelPlantillas.setVisible(true);
        ventanaPrincipal.panelInicio.repaint();


    }//GEN-LAST:event_lblPlantillasMouseClicked

    private void lblProyectosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblProyectosMouseClicked
        ventanaPrincipal.panelInicio.setVisible(false);
        ventanaPrincipal.panelContenedor.remove(ventanaPrincipal.panelInicio);

        ventanaPrincipal.panelContenedor.add(ventanaPrincipal.panelBotonesProyectos, BorderLayout.NORTH);
        ventanaPrincipal.panelContenedor.add(ventanaPrincipal.panelProyectos, BorderLayout.SOUTH);

        ventanaPrincipal.panelProyectos.setVisible(true);
        ventanaPrincipal.panelInicio.repaint();
    }//GEN-LAST:event_lblProyectosMouseClicked

private void lblUsuariosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblUsuariosMouseClicked
        ventanaPrincipal.panelInicio.setVisible(false);
        ventanaPrincipal.panelContenedor.remove(ventanaPrincipal.panelInicio);
        
        ventanaPrincipal.panelContenedor.add(ventanaPrincipal.panelUsuarios, BorderLayout.SOUTH);

        ventanaPrincipal.panelUsuarios.setVisible(true);
        ventanaPrincipal.panelInicio.repaint();
}//GEN-LAST:event_lblUsuariosMouseClicked

    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel lblPlantillas;
    private javax.swing.JLabel lblProyectos;
    private javax.swing.JLabel lblUsuarios;
    // End of variables declaration//GEN-END:variables

    private void bloquearPorPermisos() {
        //usuarios
        if (ventanaPrincipal.getPermisos().getPermisoUsuario().isEmpty() && ventanaPrincipal.getPermisos().getPermisoPerfil().isEmpty()){//no hay permisos para usuarios
            ventanaPrincipal.panelUsuarios=null;
            lblUsuarios.setVisible(false);
            lblUsuarios.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {}});
        }
        if (ventanaPrincipal.getPermisos().getPermisoMarco().isEmpty()&&ventanaPrincipal.getPermisos().getPermisoPapel().isEmpty()){
            ventanaPrincipal.panelPlantillas=null;
            lblPlantillas.setVisible(false);
            lblPlantillas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {}});
        }
        if (ventanaPrincipal.getPermisos().getPermisoProyecto().isEmpty()){
            ventanaPrincipal.panelProyectos=null;
            lblProyectos.setVisible(false);
            lblProyectos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {}});
        }
    }

}
